//
//  UpdateIssuesViewController.m
//  Care With Friends
//
//  Created by Versatile Systems, Inc on 11/5/13.
//  Copyright (c) 2013 Muludiang. All rights reserved.
//

#import "UpdateIssuesViewController.h"
#import "CWFData.h"
#import "IssueViewController.h"
#import "PlayerProfileViewController.h"

@interface UpdateIssuesViewController ()

@end

@implementation UpdateIssuesViewController

@synthesize updatesTable;
@synthesize updateSelector;

-(IBAction)changeUpdate:(id)sender{
    NSLog(@"Selector pressed %d", updateSelector.selectedSegmentIndex );
    CWFData *dataObj = [CWFData sharedInstance];
    
    if (updateSelector.selectedSegmentIndex == 0) {
     
     } else if(updateSelector.selectedSegmentIndex == 1) {
         NSLog(@" ==> %@", dataObj.getUserFollowers);
     }
    [updatesTable reloadData];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // return number of rows
    //CWFData *dataObj = [CWFData sharedInstance];
   //NSArray *t1 = [[NSArray alloc] initWithArray:[dataObj.getUserFeed valueForKey:@"problems"]];
    return 5;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"UpdateCell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    
    //CWFData *dataObj = [CWFData sharedInstance];
    //NSArray *t1 = [[NSArray alloc] initWithArray:[dataObj.getUserFeed valueForKey:@"problems"]];
    //NSDictionary  *t1 = [[NSDictionary alloc] initWithDictionary:[dataObj.getUserFeed valueForKey:@"problems"] copyItems:YES];
    
    //userNameLabel.text = [NSString stringWithFormat:@"@%@",[t1 valueForKey:@"customer"]];
    //NSLog(@" %@", t1);
    //for (NSDictionary *t2 in t1){
    if (updateSelector.selectedSegmentIndex == 0){
        [cell.textLabel setText:[NSString stringWithFormat:@"Title: %d", indexPath.row]];
        [cell.detailTextLabel setText:@"Submitter | Date"];
    }else{
        [cell.textLabel setText:[NSString stringWithFormat:@"Name: %d", indexPath.row]];
        [cell.detailTextLabel setText:@""];

    }
        //[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    //}
    //[[cell textLabel] setText:[t1 valueForKey:@"customer"]];

    // return cell
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (updateSelector.selectedSegmentIndex == 0){
        IssueViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"issue_view"];
        [self.navigationController pushViewController:dvc animated:YES];
    }
    else{
        PlayerProfileViewController *playerView = [self.storyboard instantiateViewControllerWithIdentifier:@"profile_view"];
        [self.navigationController pushViewController:playerView animated:YES];
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.

    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
